/*
* This file is a part of the open-eBackup project.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright (c) [2024] Huawei Technologies Co.,Ltd.
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*/
#ifndef BACKINTCONST_H
#define BACKINTCONST_H

#include <string>
#include <vector>
#include <functional>
#include <time.h>
#include <winsock2.h>
#include <windows.h>

namespace backint {
const uint32_t SUCCESS = 0;
const uint32_t FAILED = 1;

const uint32_t DEFAULT_CHANNELS = 1;
const std::string PATH_SEP_CHAR = "\\";
const std::string PARAM_PATH = "C:\\usr\\sap\\";

const std::string AGENT_TMP_PATH = "DataBackup\\ProtectClient\\Plugins\\GeneralDBPlugin\\tmp\\";

struct StuFileData {
    std::string m_filePath;
    int64_t m_dataLength = -1;
};

struct StuEBIDData {
    std::string m_backupID;
    std::string m_filePath;
    std::string m_destPath;
};

struct StuFileInfo {
    std::string m_backintVersion;
    std::string m_softwareVersion;
    std::string m_backupID;
    std::string m_fileName;
    std::string m_destName;
    std::vector<StuFileData> fileData;
    std::vector<StuEBIDData> m_eBIDData;
    std::string m_inputFileTitle;
};

struct StuParam {
    std::string m_userId;
    std::string m_funType;
    std::string m_parFile;
    std::string m_inputFile;
    std::string m_outFile;
    std::string m_dtBackupId;
    uint32_t m_numberOfObj = 0;
    std::string m_backupType;
    std::string m_version;
    std::string m_versionDetail;
};

struct PlugParams {
    std::string m_pid;
    std::string m_jobId;
    std::string m_subJobId;
    std::string m_dbName;
    std::string m_dataPath;
    std::string m_cachePath;
    std::string m_metaPath;
    std::string m_logPath;
    int m_channels = DEFAULT_CHANNELS;
};

uint32_t GetCpuNum();
std::string GetAgentHome();
int SafeStoi(const std::string &key);
void ParseLogFile(const std::string &filePath, int &loglevel, int &logCount, int &logMaxSize);
int GetBackupList(const std::string &filePath, StuFileInfo &stFileInfo);
uint32_t ParsePluginParams(const std::string &paramFile, PlugParams &plugParams);
uint32_t GetInFilePath(int argc, char **argv, std::string &filePath);
uint32_t WriteOutFile(const std::vector<std::string> &result, const std::string &outFile);

std::string GetFileName(const std::string &filePath);
void FindAnfSuffixFiles(const std::string& dataPath, std::vector<std::string> &files);
}  // namespace backint

#endif